//
// Created by hay boy on 2022/6/16.
//

#ifndef ALGORITHMS_ARRAYITERATOR_H
#define ALGORITHMS_ARRAYITERATOR_H
#include "ArrayList.h"
using namespace std;
template<class T>
class ArrayIterator{
public:
    typedef bidirectional_iterator_tag iterator_category;
    typedef T value_type;
    typedef ptrdiff_t difference_type;
    typedef T* pointer;
    typedef T& reference;
    explicit ArrayIterator(T* thePosition = 0){
        position = thePosition;
    }
    T& operator*()const {
        return *position;
    }
    T* operator->() const{
        return &*position;
    };
    ArrayIterator& operator++(){
        ++position;
        return *this;
    }
    ArrayIterator operator++(int){
        ArrayIterator old = *this;
        ++position;
        return old;
    }
    ArrayIterator& operator--(){
        --position;
        return *this;
    }
    ArrayIterator operator--(int){
        ArrayIterator old = *this;
        --position;
        return old;
    }
    bool operator!=(const ArrayIterator right) const{
        return position!=right.position;
    }
    bool operator==(const ArrayIterator right) const{
        return position==right.position;
    }
protected:
    T* position;
};
#endif //ALGORITHMS_ARRAYITERATOR_H
